home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / gtlayout-source.lha / LT_InitExit.c < prev    next >
C/C++ Source or Header  |  1995-09-25  |  3KB  |  162 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. BOOL __saveds __asm
  10. LT_Init()
  11. {
  12. #ifndef _GTLAYOUT_GLOBAL_H
  13.     if(SysBase)
  14.         return(TRUE);
  15.     else
  16. #endif
  17.     {
  18.         SysBase = *(struct ExecBase **)4;
  19.  
  20.         if(SysBase -> LibNode . lib_Version < 37)
  21.         {
  22. #ifndef _GTLAYOUT_GLOBAL_H
  23.             SysBase = NULL;
  24. #endif
  25.             return(FALSE);
  26.         }
  27.         else
  28.         {
  29.             V39 = (SysBase -> LibNode . lib_Version >= 39);
  30.             V40 = (SysBase -> LibNode . lib_Version >= 40);
  31.  
  32.             IntuitionBase    = OpenLibrary("intuition.library",37);
  33.             GfxBase     = (struct GfxBase *)OpenLibrary("graphics.library",37);
  34.             UtilityBase    = OpenLibrary("utility.library",37);
  35.             GadToolsBase    = OpenLibrary("gadtools.library",37);
  36.             KeymapBase    = OpenLibrary("keymap.library",37);
  37.  
  38.             if(LocaleBase = (struct LocaleBase *)OpenLibrary("locale.library",38))
  39.                 LTP_Locale = OpenLocale(NULL);
  40.  
  41.             if(IntuitionBase && GfxBase && UtilityBase && GadToolsBase && KeymapBase)
  42.             {
  43.                 if(LTP_ImageClass = MakeClass(NULL,IMAGECLASS,NULL,sizeof(ImageInfo),0))
  44.                 {
  45.                     LTP_ImageClass -> cl_Dispatcher . h_Entry = (HOOKFUNC)LTP_ImageDispatch;
  46.  
  47. #ifdef DO_LEVEL_KIND
  48.                     if(LTP_LevelClass = MakeClass(NULL,IMAGECLASS,NULL,sizeof(LevelImageInfo),0))
  49.                     {
  50.                         LTP_LevelClass -> cl_Dispatcher . h_Entry = (HOOKFUNC)LTP_LevelClassDispatcher;
  51. #else
  52.                     {
  53. #endif    /* DO_LEVEL_KIND */
  54.  
  55. #if defined(DO_POPUP_KIND) && defined(DO_BOOPSI_KIND)
  56.                         if(LTP_PopupClass = MakeClass(NULL,GADGETCLASS,NULL,sizeof(PopInfo),0))
  57.                         {
  58.                             LTP_PopupClass -> cl_Dispatcher . h_Entry = (HOOKFUNC)LTP_PopupClassDispatcher;
  59. #else
  60.                         {
  61. #endif    // DO_POPUP_KIND
  62.  
  63. #if defined(DO_TAB_KIND) && defined(DO_BOOPSI_KIND)
  64.                             if(LTP_TabClass = MakeClass(NULL,GADGETCLASS,NULL,sizeof(TabInfo),0))
  65.                             {
  66.                                 LTP_TabClass -> cl_Dispatcher . h_Entry = (HOOKFUNC)LTP_TabClassDispatcher;
  67. #else
  68.                             {
  69. #endif    // DO_TAB_KIND
  70.  
  71. #ifdef DO_PICKSHORTCUTS
  72.                                 InitSemaphore(<P_KeySemaphore);
  73. #endif    /* DO_PICKSHORTCUTS */
  74.                                 InitSemaphore(<P_LockSemaphore);
  75.  
  76.                                 NewList((struct List *)<P_LockList);
  77.                                 NewList((struct List *)<P_EmptyList);
  78.  
  79.                                 return(TRUE);
  80.                             }
  81.                         }
  82.                     }
  83.                 }
  84.             }
  85.  
  86.             LT_Exit();
  87.  
  88.             return(FALSE);
  89.         }
  90.     }
  91. }
  92.  
  93.  
  94. /*****************************************************************************/
  95.  
  96.  
  97. VOID __saveds __asm
  98. LT_Exit()
  99. {
  100. #ifndef _GTLAYOUT_GLOBAL_H
  101.     if(SysBase)
  102. #endif
  103.     {
  104. #ifdef DO_LEVEL_KIND
  105.         if(LTP_LevelClass)
  106.         {
  107.             FreeClass(LTP_LevelClass);
  108.             LTP_LevelClass = NULL;
  109.         }
  110. #endif    /* DO_LEVEL_KIND */
  111.  
  112. #if defined(DO_POPUP_KIND) && defined(DO_BOOPSI_KIND)
  113.         if(LTP_PopupClass)
  114.         {
  115.             FreeClass(LTP_PopupClass);
  116.             LTP_PopupClass = NULL;
  117.         }
  118. #endif    // DO_POPUP_KIND
  119.  
  120. #if defined(DO_TAB_KIND) && defined(DO_BOOPSI_KIND)
  121.         if(LTP_TabClass)
  122.         {
  123.             FreeClass(LTP_TabClass);
  124.             LTP_TabClass = NULL;
  125.         }
  126. #endif    // DO_TAB_KIND
  127.  
  128.         if(LTP_ImageClass)
  129.         {
  130.             FreeClass(LTP_ImageClass);
  131.             LTP_ImageClass = NULL;
  132.         }
  133.  
  134.         if(LTP_Locale)
  135.         {
  136.             CloseLocale(LTP_Locale);
  137.             LTP_Locale = NULL;
  138.         }
  139.  
  140.         CloseLibrary(LocaleBase);
  141.         LocaleBase = NULL;
  142.  
  143.         CloseLibrary(KeymapBase);
  144.         KeymapBase = NULL;
  145.  
  146.         CloseLibrary(GadToolsBase);
  147.         GadToolsBase = NULL;
  148.  
  149.         CloseLibrary(UtilityBase);
  150.         UtilityBase = NULL;
  151.  
  152.         CloseLibrary(GfxBase);
  153.         GfxBase = NULL;
  154.  
  155.         CloseLibrary(IntuitionBase);
  156.         IntuitionBase = NULL;
  157. #ifndef _GTLAYOUT_GLOBAL_H
  158.         SysBase = NULL;
  159. #endif
  160.     }
  161. }
  162.